#!/usr/bin/env python3
# -*- coding:utf-8 -*-
"""
@author:shengwei
@file:pillow_py.py
@time:2018/2/26 002615:27
"""
from PIL import Image, ImageFilter

# 打开一个jpg图像文件，注意是当前路径:
im = Image.open('./1502879400222169.jpg')
# 获得图像尺寸:
w, h = im.size

print('Original image size: %sx%s' % (w, h))
# 缩放到50%:
im.thumbnail((w // 2, h // 2))
print('Resize image to: %sx%s' % (w // 2, h // 2))
# 把缩放后的图像用jpeg格式保存:
im.save('thumbnail.jpg', 'jpeg')

# 打开一个jpg图像文件，注意是当前路径:
im = Image.open('./1502879400222169.jpg')
# 应用模糊滤镜:
im2 = im.filter(ImageFilter.BLUR)
im2.save('blur.jpg', 'jpeg')